home *** CD-ROM | disk | FTP | other *** search
- { brush.pas -- Draw figures painted with a custom brush }
-
- program Brush;
-
- {$R brush.res}
-
- uses WinTypes, WinProcs, WObjects;
-
- const
-
- id_Pattern = 200; { Resource ID of any 8-by-8 bitmap }
-
- type
-
- BrushApplication = object(TApplication)
- procedure InitMainWindow; virtual;
- end;
-
- PBrushWindow = ^BrushWindow;
- BrushWindow = object(TWindow)
- Pattern: HBrush; { Handle to brush made from bitmap }
- constructor Init(AParent: PWindowsObject; ATitle: PChar);
- destructor Done;
- virtual;
- procedure Paint(PaintDC: HDC; var PaintInfo: TPaintStruct);
- virtual;
- end;
-
-
- { BrushApplication }
-
- {- Initialize BrushApplication object's window }
- procedure BrushApplication.InitMainWindow;
- begin
- MainWindow := New(PBrushWindow, Init(nil, 'Brush'))
- end;
-
-
- { BrushWindow }
-
- {- Construct BrushWindow object }
- constructor BrushWindow.Init(AParent: PWindowsObject; ATitle: PChar);
- var
- H: HBitmap;
- begin
- TWindow.Init(AParent, ATitle);
- H := LoadBitmap(HInstance, PChar(id_Pattern));
- Pattern := CreatePatternBrush(H);
- DeleteObject(H)
- end;
-
- {- Destroy BrushWindow object and the custom brush }
- destructor BrushWindow.Done;
- begin
- DeleteObject(Pattern);
- TWindow.Done
- end;
-
- {- Display a few objects filled with the custom brush }
- procedure BrushWindow.Paint(PaintDC: HDC; var PaintInfo: TPaintStruct);
- var
- OldBrush: HBrush;
- begin
- OldBrush := SelectObject(PaintDC, Pattern);
- Rectangle(PaintDC, 10, 10, 100, 90);
- Ellipse(PaintDC, 90, 80, 200, 160);
- SelectObject(PaintDC, OldBrush)
- end;
-
- var
-
- BrushApp: BrushApplication;
-
- begin
- BrushApp.Init('BrushApp');
- BrushApp.Run;
- BrushApp.Done
- end.
-
-
- {--------------------------------------------------------------
- Copyright (c) 1991 by Tom Swan. All rights reserved.
- Revision 1.00 Date: 2/26/1991
- ---------------------------------------------------------------}
-